from django.shortcuts import HttpResponse, render
from .models import Article
import pytz
from datetime import datetime
from django.utils.timezone import now, localtime


def index(request):
    # article = Article(removed=True)
    # article = Article()
    # article.save()
    # now = datetime.now()  # TODO: 这是一个navie类型的时间
    # utc_timezone = pytz.timezone('UTC')  # TODO: 定义UTC的时区对象
    # now = now.replace(tzinfo=pytz.timezone('Asia/Shanghai'))
    # utc_now = now.astimezone(utc_timezone)
    # print(now)
    # print(utc_now)
    #
    # # TODO: replace方法
    # next_now = now.replace(day=15)
    # print(next_now)

    aticle = Article(title='efg')
    aticle.save()

    # article = Article.objects.get(pk=6)
    # article.title = 'cdef'
    # article.save()

    article = Article.objects.get(pk=7)
    create_time = article.create_time
    context = {
        'create_time': create_time
    }

    # return HttpResponse('模型常用字段')
    return render(request, 'index.html', context=context)
